//
//  WJTabBarVC.m
//  MyNewProject
//
//  Created by 王春辉 on 2020/2/22.
//  Copyright © 2020 sun. All rights reserved.
//

#import "WJTabBarVC.h"

#import "CalssifyViewController.h"
#import "AuctionViewController.h"
#import "AuctionOrderListVC.h"
#import "MinesViewController.h"

@implementation WJTabBarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray *titles = @[@"商城", @"拍场", @"历史", @"我的"];
    NSArray *defaultImages = @[@"shoping_default", @"auction_default", @"log_default", @"mine_default"];
    NSArray *selectImages = @[@"shoping_selected", @"auction_selected", @"log_selected", @"mine_selected"];
    
    
    CalssifyViewController *vc1 = [CalssifyViewController new];
    vc1.gk_backStyle = GKNavigationBarBackStyleNone;
    WJNavigationController *na1 = [[WJNavigationController alloc]
                                                   initWithRootViewController:vc1];
    
    AuctionViewController *vc2 = [[AuctionViewController alloc] init];
    vc2.gk_backStyle = GKNavigationBarBackStyleNone;
    WJNavigationController *na2 = [[WJNavigationController alloc]
                                                    initWithRootViewController:vc2];
    
    AuctionOrderListVC *vc3 = [AuctionOrderListVC new];
    vc3.gk_backStyle = GKNavigationBarBackStyleNone;
    vc3.isShowTabBar = true;
    vc3.gk_navTitle = @"成交记录";
    WJNavigationController *na3 = [[WJNavigationController alloc] initWithRootViewController:vc3];
    
    MinesViewController *vc4 = [[MinesViewController alloc] init];
    vc4.gk_backStyle = GKNavigationBarBackStyleNone;
    WJNavigationController *na4 = [[WJNavigationController alloc]
                                                    initWithRootViewController:vc4];
    self.tabBar.tintColor = [UIColor redColor];
    self.viewControllers = @[na1, na2, na3, na4];
    for (NSInteger index = 0; index < self.viewControllers.count; index++) {
        UINavigationController *na = self.viewControllers[index];
        na.hidesBottomBarWhenPushed = true;
        NSString *title = titles[index];
        NSString *imageName = defaultImages[index];
        NSString *selectImageName = selectImages[index];
        na.tabBarItem.title = title;
        na.tabBarItem.image = SKIMAGE_NAMED(imageName);
        na.tabBarItem.selectedImage = SKIMAGE_NAMED(selectImageName);
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

@interface WJNavigationController()

@end
@implementation WJNavigationController
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    } else {
        viewController.hidesBottomBarWhenPushed = NO;
    }
    [super pushViewController:viewController animated:animated];
}
@end
